<?php

namespace catchAdmin\sms\controller;

use catcher\base\CatchRequest as Request;
use catcher\CatchResponse;
use catcher\base\CatchController;
use catchAdmin\sms\model\SmsRecord as SmsRecordModel;
use think\Response;

class SmsRecord extends CatchController
{

    protected $smsRecordModel;

    /**
     *
     * @time 2022/10/14 16:16
     * @param SmsRecordModel $smsRecordModel
     * @return mixed
     */
    public function __construct(SmsRecordModel $smsRecordModel)
    {
        $this->smsRecordModel = $smsRecordModel;
    }

    /**
     *
     * @time 2022/10/14 16:16
     * @return Response
     */
    public function index(): Response
    {
        return CatchResponse::paginate($this->smsRecordModel->getLists());
    }

    /**
     *
     * @time 2022/10/14 16:16
     * @param Request $request
     * @return Response
     */
    public function save(Request $request): Response
    {
        return CatchResponse::success($this->smsRecordModel->storeBy($request->post()));
    }

    /**
     *
     * @time 2022/10/14 16:16
     * @param $id
     * @return Response
     */
    public function read($id): Response
    {
        return CatchResponse::success($this->smsRecordModel->findBy($id));
    }

    /**
     *
     * @time 2022/10/14 16:16
     * @param $id
     * @param Request $request
     * @return Response
     */
    public function update($id, Request $request): Response
    {
        return CatchResponse::success($this->smsRecordModel->updateBy($id, $request->post()));
    }

    /**
     *
     * @time 2022/10/14 16:16
     * @param $id
     * @return Response
     */
    public function delete($id): Response
    {
        return CatchResponse::success($this->smsRecordModel->deleteBy($id));
    }


}